package com.qf.day06;

/**
 * Dog的子类
 */
public class ZangAo extends Dog{

    public ZangAo() {
    }

    public ZangAo(String name, String type, String sex, int age, String vocal) {
        super(name, type, sex, age, vocal);
    }

    @Override
    public String toString() {
        return "ZangAo{" +
                "name='" + getName() + '\'' +
                ", type='" + getType() + '\'' +
                ", sex='" + getSex() + '\'' +
                ", age=" + getAge() +
                ", hungry=" + getHungry() +
                ", vocal='" + getVocal() + '\'' +
                '}';
    }

    @Override
    public int compareTo(Dog o) {

        // 先按年龄排序，如果年龄相等，再按名字的长短排序
        int age = this.getAge();
        int targAge = o.getAge();

        if (age==targAge){
            String name = this.getName();
            String targetname = o.getName();
            return name.length() - targetname.length();
        }else {
            return age - targAge;
        }

    }

    //    @Override
//    public int compareTo(Dog o) {
//
//        // 如何按照藏獒的名字进行比较大小呢
//        // 获取当前藏獒的名字
//        String name = this.getName();
//        // 获取目标藏獒的名字
//        String targetname = o.getName();
//
//        return name.compareTo(targetname);
//    }

    public static void main(String[] args) {
        ZangAo zangAo = new ZangAo();
        System.out.println(zangAo);
    }

}
